<?php

class Admin_IndexController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */

        $adminValidation = new Validations_User();
        $valid = $adminValidation->hasidentity();
        if ($valid) {
            if ($adminValidation->getUserTypeId() != 1) {
                $this->view->message = "You are not admin.";
                Zend_Auth::getInstance()->clearIdentity();
                $this->_redirect('/admin/login');
            }
        } else {
            $this->_redirect('/admin/login');
        }
        
        $this->_helper->layout->setLayout('admin');
    }

    public function indexAction() {

        $users = new Users_Model_Users();
        $rentDetails = new Ads_Model_Rentdetails();
        #users
        $this->view->totalUsers = sizeof($users->getAllUsers());
        $this->view->totalBannedUsers = sizeof($users->getBannedUsers());
        $this->view->waitingConfirms = sizeof($users->getUsersByConfirmation(false));
        $this->view->todayNew = sizeof($users->todaysNewUsers());
        #ads
        $this->view->totalPosted = sizeof($rentDetails->fetchFull());
        $this->view->todayNewPosted = sizeof($rentDetails->todayNew());
        $this->view->visible = sizeof($rentDetails->fetchAll());
        
    }

}

